# GCC Code Coverage Report

src/ObstaclePerceptionContext.cpp

Line | Branch | Exec | Source
--- | --- | --- | ---
1 |  |  | #include "rvc/ObstaclePerceptionContext.hpp"
2 |  |  |
3 |  |  | #include "rvc/NavigationAndEscapeCoordinator.hpp"
4 |  |  |
5 |  |  | namespace rvc {
6 |  |  |
7 |  | 13 | ObstaclePerceptionContext::ObstaclePerceptionContext(NavigationAndEscapeCoordinator& navigation)
8 |  | 13 | : navigation_(navigation) {}
9 |  |  |
10 |  | 18 | FusedObstacleSnapshot ObstaclePerceptionContext::ObstacleStateChanged(const ObstacleEvent& event) {
11 |  | 18 | lastUpdateTime_ = event.sampleTime;
12 |  | 18 | const auto snapshot = fuse(event);
13 |  | 18 | navigation_.FusedObstacleSnapshot(snapshot);
14 |  | 18 | return snapshot;
15 |  |  | }
16 |  |  |
17 |  | 18 | FusedObstacleSnapshot ObstaclePerceptionContext::fuse(const ObstacleEvent& event) {
18 |  | 18 | FusedObstacleSnapshot snapshot{};
19 |  |  |
20 | 14/16 ✓ Branch 2 → 3 taken 3 times. ✓ Branch 2 → 7 taken 1 time. ✓ Branch 2 → 11 taken 2 times. ✗ Branch 2 → 12 not taken. ✓ Branch 2 → 13 taken 2 times. ✓ Branch 2 → 17 taken 1 time. ✓ Branch 2 → 18 taken 1 time. ✓ Branch 2 → 19 taken 1 time. ✓ Branch 2 → 20 taken 1 time. ✓ Branch 2 → 21 taken 1 time. ✓ Branch 2 → 22 taken 1 time. ✓ Branch 2 → 23 taken 1 time. ✓ Branch 2 → 24 taken 1 time. ✓ Branch 2 → 25 taken 1 time. ✓ Branch 2 → 26 taken 1 time. ✗ Branch 2 → 27 not taken. | 18 | switch (event.kind) {
21 |  | 3 | case ObstacleEventKind::frame:
22 |  |  | case ObstacleEventKind::forwardSafe:
23 |  |  | case ObstacleEventKind::forwardSafeAfterManeuver:
24 |  |  | case ObstacleEventKind::recovered:
25 |  | 3 | frontObstacle_ = false;
26 |  | 3 | leftObstacle_ = false;
27 |  | 3 | rightObstacle_ = false;
28 |  | 6 | snapshot.kind = event.kind == ObstacleEventKind::recovered
29 | 2/2 ✓ Branch 3 → 4 taken 1 time. ✓ Branch 3 → 5 taken 2 times. | 3 | ? FusedObstacleSnapshotKind::valid
30 |  |  | : FusedObstacleSnapshotKind::forwardSafe;
31 |  | 3 | snapshot.forwardSafe = true;
32 |  | 3 | snapshot.valid = true;
33 |  | 3 | break;
34 |  | 1 | case ObstacleEventKind::forwardBlocked:
35 |  |  | case ObstacleEventKind::forwardBlockedNotSurrounded:
36 |  |  | case ObstacleEventKind::frontUpdate:
37 |  | 1 | frontObstacle_ = true;
38 |  | 2 | snapshot.kind = event.kind == ObstacleEventKind::forwardBlockedNotSurrounded
39 | 1/2 ✓ Branch 7 → 8 taken 1 time. ✗ Branch 7 → 9 not taken. | 1 | ? FusedObstacleSnapshotKind::notSurrounded
40 |  |  | : FusedObstacleSnapshotKind::forwardBlocked;
41 |  | 1 | snapshot.forwardBlocked = true;
42 |  | 1 | snapshot.rightTurnViable = !rightObstacle_;
43 |  | 1 | snapshot.leftTurnViable = !leftObstacle_;
44 |  | 1 | break;
45 |  | 2 | case ObstacleEventKind::surrounded:
46 |  | 2 | frontObstacle_ = true;
47 |  | 2 | leftObstacle_ = true;
48 |  | 2 | rightObstacle_ = true;
49 |  | 2 | snapshot.kind = FusedObstacleSnapshotKind::surrounded;
50 |  | 2 | snapshot.forwardBlocked = true;
51 |  | 2 | snapshot.surrounded = true;
52 |  | 2 | break;
53 |  | ✗ | case ObstacleEventKind::lateralOpening:
54 |  | ✗ | snapshot.kind = FusedObstacleSnapshotKind::rightTurnViable;
55 |  | ✗ | snapshot.lateralOpening = true;
56 |  | ✗ | snapshot.rightTurnViable = true;
57 |  | ✗ | break;
58 |  | 2 | case ObstacleEventKind::rightInvalidForOpening:
59 |  |  | case ObstacleEventKind::rightBlocked:
60 |  | 2 | rightObstacle_ = true;
61 |  | 4 | snapshot.kind = event.kind == ObstacleEventKind::rightBlocked
62 | 2/2 ✓ Branch 13 → 14 taken 1 time. ✓ Branch 13 → 15 taken 1 time. | 2 | ? FusedObstacleSnapshotKind::rightTurnInvalid
63 |  |  | : FusedObstacleSnapshotKind::leftTurnViable;
64 |  | 2 | snapshot.forwardBlocked = event.kind == ObstacleEventKind::rightBlocked;
65 |  | 2 | snapshot.lateralOpening = true;
66 |  | 2 | snapshot.leftTurnViable = true;
67 |  | 2 | break;
68 |  | 1 | case ObstacleEventKind::readingsDuringReverse:
69 |  |  | case ObstacleEventKind::reverseReadings:
70 |  |  | case ObstacleEventKind::flickerFrame:
71 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::reverseReadings;
72 |  | 1 | snapshot.surrounded = true;
73 |  | 1 | break;
74 |  | 1 | case ObstacleEventKind::reverseCycleSample:
75 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::reverseCycleSample;
76 |  | 1 | snapshot.surrounded = true;
77 |  | 1 | break;
78 |  | 1 | case ObstacleEventKind::maxBackupNoLateralOpening:
79 |  |  | case ObstacleEventKind::noLateralOpeningWithinLimits:
80 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::noLateralOpening;
81 |  | 1 | snapshot.surrounded = true;
82 |  | 1 | break;
83 |  | 1 | case ObstacleEventKind::partialStale:
84 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::partialStale;
85 |  | 1 | snapshot.valid = true;
86 |  | 1 | break;
87 |  | 1 | case ObstacleEventKind::invalidOrStale:
88 |  |  | case ObstacleEventKind::dropoutDuringReverse:
89 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::invalid;
90 |  | 1 | snapshot.valid = false;
91 |  | 1 | break;
92 |  | 1 | case ObstacleEventKind::oscillatingLateralReadings:
93 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::unstable;
94 |  | 1 | snapshot.valid = true;
95 |  | 1 | break;
96 |  | 1 | case ObstacleEventKind::ambiguous:
97 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::ambiguous;
98 |  | 1 | snapshot.valid = true;
99 |  | 1 | break;
100 |  | 1 | case ObstacleEventKind::rawUpdates:
101 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::consistencyApplied;
102 |  | 1 | break;
103 |  | 1 | case ObstacleEventKind::sideUpdate:
104 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::alignedSnapshotTBD;
105 |  | 1 | break;
106 |  | 1 | case ObstacleEventKind::sensorSnapshot:
107 |  |  | case ObstacleEventKind::TBD:
108 |  | 1 | snapshot.kind = FusedObstacleSnapshotKind::snapshot;
109 |  | 1 | break;
110 |  |  | }
111 |  |  |
112 |  | 18 | return snapshot;
113 |  |  | }
114 |  |  |
115 |  |  | } // namespace rvc
116 |  |  |